﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain;
using Dao.Interface;
using NHibernate.Criterion;

namespace Dao
{
    public class AreaRepository : Repository<Area>, IAreaRepository
    {
        /// <summary>
        /// 获取分区集合
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="delete">是否删除</param>
        /// <returns></returns>
        public IList<Area> LoadAllArea(object userID, bool delete)
        {
            return this.Session.CreateCriteria(typeof(Area))
                .Add(Restrictions.Eq("MarkDelete", delete))
                .CreateCriteria("NoteBook")
                .CreateCriteria("UserInfo").Add(Restrictions.Eq("ID", userID))
                .List<Area>();
        }

        /// <summary>
        /// 获取共享分区集合
        /// </summary>
        /// <returns></returns>
        public IList<Area> LoadAllShareArea()
        {
            return this.Session.CreateCriteria(typeof(Area))
                .Add(Restrictions.Eq("MarkDelete", false))
                .Add(Restrictions.Eq("Share", true))
                .List<Area>();
        }
    }
}
